package com.leancloud.circle;

import com.alibaba.android.arouter.launcher.ARouter;

import tech.com.commoncore.basecomponent.ServiceFactory;
import tech.com.commoncore.user.CurrentUser;
import tech.com.commoncore.utils.ToastUtil;

public class LoginCallUtil {

    public static void verify_Toset(Back passBack) {
        CurrentUser user = ServiceFactory.getInstance().getLoginService().getCurrentUser();
        if (user == null || !user.isLogin()) {
            ToastUtil.show("您还没有登录哦");
        } else {
            passBack.passBack();
//            verify_ToLogin(passBack);
        }
    }

    public static void verify_ToLogin(Back passBack) {
        CurrentUser user = ServiceFactory.getInstance().getLoginService().getCurrentUser();
        if (user == null || !user.isLogin()) {
            ARouter.getInstance().build("/login/login").greenChannel().navigation();
        } else {
            passBack.passBack();
        }
    }

    public static abstract class Back {
        protected abstract void passBack();
    }
}
